package com.chengyu.core.service.ty;

import com.chengyu.core.domain.form.OrderRefundForm;
import com.chengyu.core.domain.form.OrderRefundSearchForm;
import com.chengyu.core.domain.form.TyOrderRefundForm;
import com.chengyu.core.domain.form.TyOrderRefundSearchForm;
import com.chengyu.core.domain.result.OrderRefundResult;
import com.chengyu.core.domain.result.TyOrderRefundResult;
import com.chengyu.core.exception.ServiceException;
import com.chengyu.core.model.SysAdmin;
import com.chengyu.core.model.TyOrderRefund;
import com.chengyu.core.model.UmsMember;
import com.chengyu.core.model.UmsShop;

import java.util.List;

public interface TyOrderRefundService {

    /**
     * 退款列表
     *
     * @param form
     * @param page
     * @param pageSize
     * @return List<TyOrderRefund>
     * @author LeGreen
     * @date 2022/4/29
     */
    List<TyOrderRefund> getRefundList(TyOrderRefundSearchForm form, Integer page, Integer pageSize);

    /**
     * 退款详情
     *
     * @param refundId
     * @return OrderRefundResult
     * @author LeGreen
     * @date 2022/4/29
     */
    TyOrderRefundResult getOrderRefund(Integer refundId);

    /**
     * 申请退款
     *
     * @param member
     * @param form
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void applyRefund(UmsMember member, TyOrderRefundForm form) throws ServiceException;

    /**
     * 同意退款
     *
     * @param shop
     * @param refundId
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void agreeRefund(UmsShop shop, Integer refundId) throws ServiceException;

    /**
     * 拒绝退款
     *
     * @param shop
     * @param refundId
     * @param reason
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void refuseRefund(UmsShop shop, Integer refundId, String reason) throws ServiceException;

    /**
     * 申请客服介入
     *
     * @param member
     * @param refundId
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void applyCustomerServiceIn(UmsMember member, Integer refundId) throws ServiceException;

    /**
     * 平台客服同意退款
     *
     * @param admin
     * @param refundId
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void agreeRefundByCustomer(SysAdmin admin, Integer refundId) throws ServiceException;

    /**
     * 平台客服判定拒绝退款，交易关闭
     *
     * @param admin
     * @param refundId
     * @param reason
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void refuseRefundByCustomer(SysAdmin admin, Integer refundId, String reason) throws ServiceException;

    /**
     * 买家进行退货
     *
     * @param member
     * @param refundId
     * @param deliveryType
     * @param deliveryNo
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void salesReturnByMember(UmsMember member, Integer refundId, String deliveryType, String deliveryNo) throws ServiceException;

    /**
     * 卖家确认收货,退款完成
     *
     * @param shop
     * @param refundId
     * @throws ServiceException 业务异常
     * @author LeGreen
     * @date 2022/4/29
     */
    void confirmReceiveByShop(UmsShop shop, Integer refundId) throws ServiceException;

    /**
     * 卖家超时未处理售后,自动同意
     *
     * @param refundNo
     * @author LeGreen
     * @date 2022/5/6
     */
    void autoAgreeRefund(String refundNo) throws ServiceException;

    /**
     * 买家超时未寄货，自动取消
     *
     * @param refundNo
     * @author LeGreen
     * @date 2022/5/6
     */
    void autoCancelRefund(String refundNo);

    /**
     * 卖家超时未确认收货,自动确认
     *
     * @param refundNo
     * @author LeGreen
     * @date 2022/5/6
     */
    void autoConfirmRefund(String refundNo);

    /**
     * 取消售后申请
     *
     * @param member
     * @param refundId
     * @author LeGreen
     * @date 2022/5/16
     */
    void cancelRefund(UmsMember member, Integer refundId) throws ServiceException;

    /**
     * 退款详情
     *
     * @param detailId
     * @return OrderRefundResult
     * @author LeGreen
     * @date 2022/4/29
     */
    TyOrderRefundResult getOrderRefundByDetailId(Integer detailId);

    /**
     * 根据退款单号获取退款
     *
     * @param refundNo
     * @return TyOrderRefund
     * @author LeGreen
     * @date 2022/6/9
     */
    TyOrderRefund getOrderRefundByRefundNo(String refundNo);

    /**
     * 退款成功回调
     *
     * @param refund
     * @author LeGreen
     * @date 2022/6/9
     */
    void refundSusCallback(TyOrderRefund refund);
}